package hlhj.fhp.supreme.activitys

import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.lzy.okgo.OkGo
import com.lzy.okgo.model.Response
import fhp.hlhj.giantfold.utils.LogUtil
import fhp.hlhj.giantfold.utils.ToastUtils
import hlhj.fhp.supreme.BaseAty
import hlhj.fhp.supreme.Contents
import hlhj.fhp.supreme.R
import hlhj.fhp.supreme.javabean.PhoneBean
import hlhj.fhp.supreme.network.Urls
import hlhj.fhp.supreme.utils.JsonCallBack
import kotlinx.android.synthetic.main.activity_group_buy_aty.*

class GroupBuyAty : BaseAty() {
    private var pp=5
    override fun getContentId(): Int {
        return R.layout.activity_group_buy_aty
    }


    override fun initView() {
        OkGo.post<PhoneBean>(Urls.BaseUrl+Urls.PHONE)
                .params("type","gorup_prompt")
                .execute(object :JsonCallBack<PhoneBean>(this@GroupBuyAty){
                    override fun onSuccess(response: Response<PhoneBean>?) {
                        val body = response!!.body()
                        if (body.code==1){
                            tvDesc.text=body.data.gorup_prompt

                        }else{
                            ToastUtils.toast(this@GroupBuyAty,body.msg)
                        }
                    }
                })

        btStright.setOnClickListener {
                pp=5
                btStright.setBackgroundResource(R.drawable.yellow_border)
                btStright.setTextColor(resources.getColor(R.color.them_yellow))
                btTuangou.setBackgroundResource(R.drawable.grey_border)
                btTuangou.setTextColor(resources.getColor(R.color.text_333))
        }
        btTuangou.setOnClickListener {
                pp=10
                btTuangou.setBackgroundResource(R.drawable.yellow_border)
                btTuangou.setTextColor(resources.getColor(R.color.them_yellow))
                btStright.setBackgroundResource(R.drawable.grey_border)
                btStright.setTextColor(resources.getColor(R.color.text_333))
        }

        btCommit.setOnClickListener {
            LogUtil.log(Contents.FIVE+"---"+Contents.TEN)
            val intent = Intent(this, PayAty::class.java)
            intent.putExtra("et",5)
            intent.putExtra("pp",pp)
            intent.putExtra("money",if (pp==5)Contents.FIVE else Contents.TEN)
            intent.putExtra("type","2")
            startActivity(intent)
            finish()
        }
        btExit.setOnClickListener {
            finish()
        }
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (resultCode==-1)finish()
    }

}
